import pandas as pd

# 读取 Cluster.xlsx 文件
df = pd.read_excel('./data/Cluster.xlsx')

# 打印列名以检查实际的列名
print(df.columns)

# 选择 Cluster_number 列
cluster_numbers = df['Cluster_number'].tolist()

# 生成 JavaScript 文件内容
js_content = "const labels = [\n"
for number in cluster_numbers:
    js_content += f"  {number},\n"
js_content = js_content.rstrip(",\n") + "\n];"

# 将内容写入文件
with open('labels.js', 'w', encoding='utf-8') as file:
    file.write(js_content)

print("JavaScript 文件已成功保存。")
